home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 2).iso / 1133 / itest.c < prev    next >
C/C++ Source or Header  |  1997-04-16  |  2KB  |  67 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "nndefs.h"
  5. #include "params.h"
  6. #include "datamat.h"
  7. #include "neural.h"
  8.        
  9.     NEURAL *tneural;                  
  10.     void Logit(const char* fmt, ...);
  11.     FILE *fd;
  12.     float *Ivec,*Ovec;
  13.     char buf[128], fname[128], m1[16],m2[16];    
  14.     int i;
  15.  
  16. void main () {
  17.  
  18.     unlink ("nnlib.log");
  19.     printf ("\nNNLIB interrogation test program v1.2\n    Enter END to an input prompt to exit program\n\n");
  20.     printf ("Enter model name = ");
  21.     gets (buf);
  22.     if ((buf[0]=='E') || (buf[0]=='e')) exit(0);
  23.     printf ("\n");
  24.     
  25.     strcpy (fname,buf);
  26.     strcat (fname,".ENN");
  27.     tneural = LoadNetwork(fname);
  28.     if (tneural == NULL) {
  29.            printf ("Load error <%s>\n",buf);
  30.            exit(1); 
  31.        }
  32.  
  33.     fd = fopen("itest.dmp","w");
  34.     //DumpNeural(tneural,fd);
  35.     fclose (fd);
  36.  
  37.     Ivec = (float*) malloc (sizeof(float)*tneural->m_ninputs);
  38.     Ovec = (float*) malloc (sizeof(float)*tneural->m_noutputs);
  39.     
  40. loop:
  41.  
  42.     for (i=0;i<tneural->m_ninputs;i++) {
  43.         sprintf (m1,tneural->m_dm->m_icoldesc[i].format,tneural->m_dm->m_icoldesc[i].min);
  44.         sprintf (m2,tneural->m_dm->m_icoldesc[i].format,tneural->m_dm->m_icoldesc[i].max);
  45.         printf ("Enter %8s (range %10s to %10s ) = ",tneural->m_dm->m_icoldesc[i].vlab,m1,m2);
  46.         gets (buf);
  47.         if ((buf[0]=='E') || (buf[0]=='e')) goto getout;
  48.         sscanf (buf,"%f",&Ivec[i]);
  49.     }
  50.     printf ("\n");
  51.     NInterrogate(tneural,Ivec,Ovec);
  52.     for (i=0;i<tneural->m_noutputs;i++) {
  53.         sprintf (m1,tneural->m_dm->m_ocoldesc[i].format,Ovec[i]);
  54.         printf ("\n%8s = %10s",tneural->m_dm->m_ocoldesc[i].vlab,m1);
  55.     }
  56.     printf ("\n\n");
  57.     
  58.     goto loop;
  59.  
  60. getout:
  61.     free (Ivec);
  62.     free (Ovec);
  63.     NDeleteNeural(tneural);
  64.     exit(1);
  65.     
  66. }
  67.